function getDir(fullPath){
	var pos = fullPath.lastIndexOf("\\");
	return fullPath.substring(0, pos);
}

function thgw(cmd, bWithFile){
	var WshShell = new ActiveXObject("WScript.Shell");
	WshShell.CurrentDirectory = getDir(ActiveDoc.PathName)
	WshShell.Run('thgw --nofork ' + cmd + " " + (bWithFile ? ActiveDoc.PathName : ""));
}